package org.arch_learn.mvc.auto_config;

import org.arch_learn.flashboot.autoconfigure.Bean;
import org.arch_learn.flashboot.autoconfigure.Configuration;
import org.arch_learn.flashboot.autoconfigure.EnableConfigurationProperties;
import org.arch_learn.mvc.servlet.GeneralDispatcherServlet;

import javax.servlet.ServletException;

@Configuration
@EnableConfigurationProperties(MvcProperties.class)
public class MvcAutoConfiguration {

    @Bean
    public GeneralDispatcherServlet generalDispatcherServlet(MvcProperties mvcProperties) throws ServletException {
        GeneralDispatcherServlet generalDispatcherServlet = new GeneralDispatcherServlet(mvcProperties.getName(), mvcProperties.getContextPath());
//        Integer loadOnStartUp = mvcProperties.getLoadOnStartUp();
//        if (loadOnStartUp > 0) generalDispatcherServlet.init();
        return generalDispatcherServlet;
    }
}
